﻿namespace ACCOUNTING
{
    using ACCOUNTING.LVY.Business;
    using ACCOUNTING.My;
    using ACCOUNTING.My.Resources;
    using C1.Win.C1FlexGrid;
    using C1.Win.C1FlexGrid.Util.BaseControls;
    using Microsoft.VisualBasic;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Runtime.CompilerServices;
    using System.Windows.Forms;

    [DesignerGenerated]
    public class Frm_TimQuocGia : Form
    {
        private static List<WeakReference> __ENCList = new List<WeakReference>();
        [AccessedThroughProperty("CmdAddNew")]
        private Button _CmdAddNew;
        [AccessedThroughProperty("CmdCancel")]
        private Button _CmdCancel;
        [AccessedThroughProperty("CmdOK")]
        private Button _CmdOK;
        [AccessedThroughProperty("TxtCode")]
        private TextBox _TxtCode;
        [AccessedThroughProperty("TxtName")]
        private TextBox _TxtName;
        [AccessedThroughProperty("VSlist")]
        private C1.Win.C1FlexGrid.C1FlexGrid _VSlist;
        private IContainer components;
        private string mValueReturn;
        private DataView pData;

        public Frm_TimQuocGia()
        {
            base.Activated += new EventHandler(this.Frm_TimQuocGia_Activated);
            base.Load += new EventHandler(this.Frm_TimQuocGia_Load);
            List<WeakReference> list = __ENCList;
            lock (list)
            {
                __ENCList.Add(new WeakReference(this));
            }
            this.mValueReturn = "";
            this.InitializeComponent();
        }

        private void CmdAddNew_Click(object sender, EventArgs e)
        {
            this.ValueReturn = "";
            this.TxtCode.Text = "";
            this.TxtName.Text = "";
            MyProject.Forms.Frm_DMQuocGia.ShowDialog();
        }

        private void CmdCancel_Click(object sender, EventArgs e)
        {
            this.ValueReturn = "";
            this.TxtCode.Text = "";
            this.TxtName.Text = "";
            this.Dispose();
        }

        private void CmdOK_Click(object sender, EventArgs e)
        {
            if (this.VSlist.Rows.Count > 1)
            {
                this.mValueReturn = this.VSlist[this.VSlist.Row, 0].ToString().Trim() + "|" + this.VSlist[this.VSlist.Row, 1].ToString().Trim() + "|" + this.VSlist[this.VSlist.Row, 2].ToString().Trim();
            }
            this.Close();
        }

        [DebuggerNonUserCode]
        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void Frm_TimQuocGia_Activated(object sender, EventArgs e)
        {
            this.TxtCode.Focus();
        }

        private void Frm_TimQuocGia_Load(object sender, EventArgs e)
        {
            this.loadData();
        }

        [DebuggerStepThrough]
        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Frm_TimQuocGia));
            this.TxtName = new TextBox();
            this.TxtCode = new TextBox();
            this.VSlist = new C1.Win.C1FlexGrid.C1FlexGrid();
            this.CmdAddNew = new Button();
            this.CmdCancel = new Button();
            this.CmdOK = new Button();
            this.VSlist.BeginInit();
            this.SuspendLayout();
            Point point = new Point(0x5e, 2);
            this.TxtName.Location = point;
            this.TxtName.Name = "TxtName";
            Size size = new Size(300, 20);
            this.TxtName.Size = size;
            this.TxtName.TabIndex = 5;
            point = new Point(1, 2);
            this.TxtCode.Location = point;
            this.TxtCode.Name = "TxtCode";
            size = new Size(90, 20);
            this.TxtCode.Size = size;
            this.TxtCode.TabIndex = 4;
            this.VSlist.AllowEditing = false;
            this.VSlist.BorderStyle = C1.Win.C1FlexGrid.Util.BaseControls.BorderStyleEnum.FixedSingle;
            this.VSlist.ColumnInfo = "3,0,0,0,0,85,Columns:0{Caption:\"Khoa\";Visible:False;}\t1{Width:90;Caption:\"Ma\";}\t2{Caption:\"Ten\";}\t";
            this.VSlist.ExtendLastCol = true;
            this.VSlist.FocusRect = FocusRectEnum.None;
            point = new Point(1, 0x19);
            this.VSlist.Location = point;
            this.VSlist.Name = "VSlist";
            this.VSlist.Rows.Count = 1;
            this.VSlist.Rows.DefaultSize = 0x11;
            this.VSlist.SelectionMode = SelectionModeEnum.Row;
            size = new Size(0x18a, 0x155);
            this.VSlist.Size = size;
            this.VSlist.StyleInfo = manager.GetString("VSlist.StyleInfo");
            this.VSlist.TabIndex = 6;
            this.VSlist.VisualStyle = VisualStyle.Office2007Blue;
            this.CmdAddNew.Image = (Image) manager.GetObject("CmdAddNew.Image");
            this.CmdAddNew.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(3, 370);
            this.CmdAddNew.Location = point;
            this.CmdAddNew.Name = "CmdAddNew";
            size = new Size(0x4d, 0x18);
            this.CmdAddNew.Size = size;
            this.CmdAddNew.TabIndex = 9;
            this.CmdAddNew.Text = "&Th\x00eam";
            this.CmdAddNew.UseVisualStyleBackColor = true;
            this.CmdCancel.DialogResult = DialogResult.Cancel;
            this.CmdCancel.Image = (Image) manager.GetObject("CmdCancel.Image");
            this.CmdCancel.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(0x139, 370);
            this.CmdCancel.Location = point;
            this.CmdCancel.Name = "CmdCancel";
            size = new Size(0x4f, 0x18);
            this.CmdCancel.Size = size;
            this.CmdCancel.TabIndex = 8;
            this.CmdCancel.Text = "&Tho\x00e1t";
            this.CmdCancel.UseVisualStyleBackColor = true;
            this.CmdOK.Image = (Image) manager.GetObject("CmdOK.Image");
            this.CmdOK.ImageAlign = ContentAlignment.MiddleLeft;
            point = new Point(230, 370);
            this.CmdOK.Location = point;
            this.CmdOK.Name = "CmdOK";
            size = new Size(0x4e, 0x18);
            this.CmdOK.Size = size;
            this.CmdOK.TabIndex = 7;
            this.CmdOK.Text = "&Chọn";
            this.CmdOK.UseVisualStyleBackColor = true;
            SizeF ef = new SizeF(6f, 13f);
            this.AutoScaleDimensions = ef;
            this.AutoScaleMode = AutoScaleMode.Font;
            this.BackgroundImage = ACCOUNTING.My.Resources.Resources.bgleft;
            size = new Size(0x18e, 0x18d);
            this.ClientSize = size;
            this.ControlBox = false;
            this.Controls.Add(this.CmdAddNew);
            this.Controls.Add(this.CmdCancel);
            this.Controls.Add(this.CmdOK);
            this.Controls.Add(this.VSlist);
            this.Controls.Add(this.TxtName);
            this.Controls.Add(this.TxtCode);
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.Name = "Frm_TimQuocGia";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "TIM QUOC GIA";
            this.VSlist.EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        public void loadData()
        {
            clsDMQuocGia gia = new clsDMQuocGia();
            this.pData = new DataView(gia.GetList());
            this.VSlist.DataSource = this.pData;
            this.VSlist.Cols[0].Visible = false;
            this.VSlist.Cols[1].Width = 100;
            this.VSlist.Cols[2].Width = 200;
            this.VSlist[0, 1] = modGeneral.Tranlated("M\x00e3 quốc gia", "");
            this.VSlist[0, 2] = modGeneral.Tranlated("T\x00ean quốc gia", "");
        }

        public void Search(string strCode, string strName)
        {
            string left = "";
            if (strCode.Trim() != "")
            {
                left = "Ma LIKE '" + strCode + "%'";
            }
            if (strName.Trim() != "")
            {
                left = Conversions.ToString(Microsoft.VisualBasic.CompilerServices.Operators.ConcatenateObject(left, Interaction.IIf(left.Trim() != "", " And Ten LIKE '" + strName + "%'", " Ten LIKE '" + strName + "%'")));
            }
            this.pData.RowFilter = left;
            if (this.VSlist.Rows.Count != 1)
            {
                this.VSlist.Select(1, 0, 1, this.VSlist.Cols.Count - 1);
            }
        }

        private void TxtCode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
            }
            if (e.KeyCode == Keys.Down)
            {
                if (this.VSlist.Row < (this.VSlist.Rows.Count - 1))
                {
                    this.VSlist.Select(this.VSlist.Row + 1, 1);
                }
                e.SuppressKeyPress = true;
            }
            if (e.KeyCode == Keys.Up)
            {
                if (this.VSlist.Row > 1)
                {
                    this.VSlist.Select(this.VSlist.Row - 1, 1);
                }
                e.SuppressKeyPress = true;
            }
        }

        private void TxtCode_TextChanged(object sender, EventArgs e)
        {
            this.Search(this.TxtCode.Text, this.TxtName.Text);
        }

        private void TxtName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Return)
            {
                this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
            }
            if (e.KeyCode == Keys.Down)
            {
                if (this.VSlist.Row < (this.VSlist.Rows.Count - 1))
                {
                    this.VSlist.Select(this.VSlist.Row + 1, 1);
                }
                e.SuppressKeyPress = true;
            }
            if (e.KeyCode == Keys.Up)
            {
                if (this.VSlist.Row > 1)
                {
                    this.VSlist.Select(this.VSlist.Row - 1, 1);
                }
                e.SuppressKeyPress = true;
            }
        }

        private void TxtName_TextChanged(object sender, EventArgs e)
        {
            this.Search(this.TxtCode.Text, this.TxtName.Text);
        }

        private void VSlist_DoubleClick(object sender, EventArgs e)
        {
            this.CmdOK_Click(RuntimeHelpers.GetObjectValue(sender), e);
        }

        internal virtual Button CmdAddNew
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdAddNew;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdAddNew_Click);
                if (this._CmdAddNew != null)
                {
                    this._CmdAddNew.Click -= handler;
                }
                this._CmdAddNew = value;
                if (this._CmdAddNew != null)
                {
                    this._CmdAddNew.Click += handler;
                }
            }
        }

        internal virtual Button CmdCancel
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdCancel;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdCancel_Click);
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click -= handler;
                }
                this._CmdCancel = value;
                if (this._CmdCancel != null)
                {
                    this._CmdCancel.Click += handler;
                }
            }
        }

        internal virtual Button CmdOK
        {
            [DebuggerNonUserCode]
            get
            {
                return this._CmdOK;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.CmdOK_Click);
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click -= handler;
                }
                this._CmdOK = value;
                if (this._CmdOK != null)
                {
                    this._CmdOK.Click += handler;
                }
            }
        }

        internal virtual TextBox TxtCode
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtCode;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtCode_TextChanged);
                KeyEventHandler handler2 = new KeyEventHandler(this.TxtCode_KeyDown);
                if (this._TxtCode != null)
                {
                    this._TxtCode.TextChanged -= handler;
                    this._TxtCode.KeyDown -= handler2;
                }
                this._TxtCode = value;
                if (this._TxtCode != null)
                {
                    this._TxtCode.TextChanged += handler;
                    this._TxtCode.KeyDown += handler2;
                }
            }
        }

        internal virtual TextBox TxtName
        {
            [DebuggerNonUserCode]
            get
            {
                return this._TxtName;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.TxtName_TextChanged);
                KeyEventHandler handler2 = new KeyEventHandler(this.TxtName_KeyDown);
                if (this._TxtName != null)
                {
                    this._TxtName.TextChanged -= handler;
                    this._TxtName.KeyDown -= handler2;
                }
                this._TxtName = value;
                if (this._TxtName != null)
                {
                    this._TxtName.TextChanged += handler;
                    this._TxtName.KeyDown += handler2;
                }
            }
        }

        public string ValueReturn
        {
            get
            {
                return this.mValueReturn;
            }
            set
            {
                this.mValueReturn = value;
            }
        }

        internal virtual C1.Win.C1FlexGrid.C1FlexGrid VSlist
        {
            [DebuggerNonUserCode]
            get
            {
                return this._VSlist;
            }
            [MethodImpl(MethodImplOptions.Synchronized), DebuggerNonUserCode]
            set
            {
                EventHandler handler = new EventHandler(this.VSlist_DoubleClick);
                if (this._VSlist != null)
                {
                    this._VSlist.DoubleClick -= handler;
                }
                this._VSlist = value;
                if (this._VSlist != null)
                {
                    this._VSlist.DoubleClick += handler;
                }
            }
        }
    }
}

